﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
    xmlns:ddhelpers="clr-namespace:UColor.Core.Helpers;assembly=UColor.Core"
    xmlns:helpers="clr-namespace:UColor.WPF.Helpers">

    <ddhelpers:GlobalResource x:Key="ScrollViewerResource" Assembly="UColor.Core" XamlPath="Window/ScrollBar.xaml" Key="ScrollViewer" />
    <Style TargetType="helpers:CodeViewControl">
        <Setter Property="Padding" Value="20" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="helpers:CodeViewControl">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Border Grid.RowSpan="2" BorderThickness="1" BorderBrush="#FFD9D9D9" Background="White" />
                        <dx:DXExpander x:Name="SearchExpander">
                            <Border BorderBrush="#FFD9D9D9" Margin="1,1,1,0" BorderThickness="0,0,0,1" VerticalAlignment="Bottom" Background="#FFF5F5F5">
                                <StackPanel x:Name="SearchPanel" MinHeight="24" Orientation="Horizontal" Margin="10">
                                    <TextBox x:Name="TextInput" VerticalContentAlignment="Center" Width="250" Padding="4,0,0,1"/>
                                    <Button Content="Find Next" x:Name="SearchButton" Margin="5,0,0,0" />
                                    <TextBlock x:Name="NotFoundText" Text="Not found" Margin="5,0,0,0" VerticalAlignment="Center" Visibility="Collapsed" Foreground="#FF9A9A9A"/>
                                    <TextBlock x:Name="NoMoreFoundText" Text="No more occurrences found" Margin="5,0,0,0" VerticalAlignment="Center" Visibility="Collapsed" Foreground="#FF9A9A9A"/>
                                </StackPanel>
                            </Border>
                        </dx:DXExpander>
                        <ScrollViewer  Style="{Binding Path=Resource, Source={StaticResource DemoScrollViewerResource}}" Grid.Row="1" x:Name="RichTextBoxScrollViewer" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Margin="2">
                            <Grid Background="Transparent" Margin="{TemplateBinding Padding}">
                                <RichTextBox Background="White" x:Name="CodePresenter" FontFamily="Courier New" FontSize="12" FlowDirection="LeftToRight" IsReadOnly="True" 
                                             BorderBrush="Transparent" BorderThickness="0" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Disabled" HorizontalAlignment="Left" MaxWidth="5000">
                                    <!--ONLY SL<RichTextBox.TextWrapping>
                                    <TextWrapping>NoWrap</TextWrapping>
                                </RichTextBox.TextWrapping>ONLY SL-->
                                </RichTextBox>
                                <Canvas x:Name="SelectionCanvas" IsHitTestVisible="False"/>
                            </Grid>
                        </ScrollViewer>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
